<template>
	<view>
		<view class="content">
			<view
			class="box peoplebox"
			v-for="(data,index) in info"
			:key="index"
			 @click="choosePeople(data,index)"
			 :class="isActive==index?'tag':''"
			 >

				<view class="name">{{data.name}}</view>
				<view class="noRealname" v-if="data.isVerified==1">未实名</view>
				<view class="introduce">
					<text v-if="data.sex==1">男</text><text v-if="data.sex==2">女</text>
					<text v-if="data.relation==0">本人</text><text v-if="data.relation==1">亲戚</text>
					<text>{{data.age || 0}}岁</text>
					<text>{{data.relation?data.relation:""}}</text>
					
				</view>
			</view>
			<view @click="addpersonal" class="box add_people" v-if="info.length<number.patientCount">
				<image class="icon_add" src="../static/images/icon_add.png"></image>
				<view>添加就诊人</view>
				<view style="color: #E26D5F;font-size: 26rpx;">*最多添加{{number.patientCount}}人</view>
			</view>
			<!-- <button v-if="choosePeopleInfo.isVerified==1" class="arc_button btn_appointment">实名认证</button> -->
		</view>
	</view>
</template>


<script>
	import { patientList,getMaxpeople } from '@/api/prescribing.js';
	export default{
		data(){
			return{
				isActive:-1,
				info:[],
				choosePeopleInfo:[],
				queryParams: {
				  pageNum:1,
				  pageSize:10,
				},
				number:{}
			}
		},
		onShow() {
			this.patientListInfo();
			this.peopleNumber();
		},
		mounted(){
			this.patientListInfo();
			this.choosePeople();
		},
		methods:{
			peopleNumber(){
				let _this = this
				uni.showLoading({
					title:'加载中'
				})
				getMaxpeople().then(res => {
					_this.number=res.data;
					console.log("numbernumber",JSON.stringify(res.data))
					uni.hideLoading()
				}).catch(res => {
					uni.hideLoading()
				});
			},
			patientListInfo(){
				let _this = this
				_this.isActive=-1;
				uni.showLoading({
					title:'加载中'
				})
				patientList(_this.queryParams).then(res => {
					_this.info=res.rows;
					// console.log("^^^^^infoinfo===",JSON.stringify(_this.info))
					_this.ideas=res.rows[0];
					uni.hideLoading()
				}).catch(res => {
					uni.hideLoading()
				});
			},
			choosePeople(data,index){
				this.isActive=index;
				this.choosePeopleInfo=data;
				this.$emit("send",this.choosePeopleInfo)
			},
			addpersonal(){
				uni.navigateTo({
				    url:"/pagesSub-My/my/addPatients"
				})
			}
		}
		}
</script>

<style scoped>
	.tag{
		border: 2rpx solid #5BD6B4;
	}
	.content{
		padding: 30rpx;
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
	}
	.content>.box{
		width: 200rpx;
		height: 130rpx;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		margin-bottom: 20rpx;
	}
	.content>.peoplebox{
		padding-left: 20rpx;
		padding-top: 20rpx;
		position: relative;
	}
	.name{
		font-size: 33rpx;
	}
	.introduce{
		font-size: 28rpx;
	}
	.introduce text{
		margin-right: 15rpx;
	}
	.icon_add{
		width: 50rpx;
		height: 45rpx;
	}
	.add_people{
		text-align: center;
		font-size: 30rpx;
		padding: 10rpx;
	}
	.noRealname{
		background-color: #5BD6B4;
		width: 35%;
		height: 30rpx;
		position: absolute;
		top:0;
		right: 0;
		color: #FFFFFF;
		font-size: 22rpx;
		text-align: center;
	}
	.btn_appointment{
		margin-top: 40rpx;
		background: -webkit-linear-gradient(#77E2A4, #4CCDBC);
		color: #FFFFFF;
	}
</style>
